<template>
  <div>
    <el-card class="box-card">
      <div slot="header" class="title">
        <span>管理员登录</span>
      </div>
      <div>
        <el-form ref="form" :model="login" label-width="80px">
          <el-form-item label="账号">
            <el-input v-model="login.adminTel"></el-input>
          </el-form-item>
          <el-form-item label="密码">
            <el-input v-model="login.adminPwd" show-password></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="logindo">登录</el-button>
            <el-button>取消</el-button>
          </el-form-item>
        </el-form>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      login: {
        adminTel: "",
        adminPwd: "",
      },
      admin: {},
    };
  },
  methods: {
    logindo() {
      this.$axios.post("/admin/login", this.login).then((res) => {
        if (res.data.code == 200) {
          this.admin = res.data.data.tAdmin;
          sessionStorage.setItem("menuList",JSON.stringify(res.data.data.menuList));
          sessionStorage.setItem("adminImg", this.admin.adminImg);
          sessionStorage.setItem("adminName", this.admin.adminName);
          sessionStorage.setItem("adminId", this.admin.adminId);
          this.$router.push("/index");
        } else {
          this.$message.error("账号或密码错误");
        }
      });
    },
  },
};
</script>

<style scoped>
.login-container {
  border-radius: 10px;
  margin: 0px auto;
  width: 350px;
  padding: 30px 35px 15px 35px;
  background: #fff;
  border: 1px solid #eaeaea;
  text-align: left;
  box-shadow: 0 0 20px 2px rgba(0, 0, 0, 0.1);
}
.title {
  margin: 0px auto 40px auto;
  text-align: center;
  color: #505458;
}
.remember {
  margin: 0px 0px 35px 0px;
}
.code-box {
  text-align: right;
}
.codeimg {
  height: 40px;
}
.text {
  font-size: 14px;
}

.item {
  margin-bottom: 18px;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}
.clearfix:after {
  clear: both;
}

.box-card {
  width: 480px;
  margin: 180px auto;
}
</style>